#include "../logs/A_log.hpp"

using namespace Alpaca;

void test_log(const std::string &name)
{
    INFO("%s", "测试开始");
    Logger::ptr logger = Getlogger(name);
    // Logger::ptr logger = LoggerManager::getInstance().GetLogger("Async_logger");
    logger->debug("%s", "测试日志");
    logger->info("%s", "测试日志");
    logger->warn("%s", "测试日志");
    logger->error("%s", "测试日志");
    logger->fatal("%s", "测试日志");

    // size_t count = 0;
    // while (count < 500000)
    // {
    //     FATAL("测试日志-%d", count++);
    // }

    INFO("%s", "测试完毕");
}

int main()
{
    std::unique_ptr<LoggerBuilder> builder(new GlobalLoggerBuilder());
    builder->BuildLoggerLevel(LogLevel::value::DEBUG);
    builder->BuildLoggerName("Async_logger");
    builder->BuildLoggerType(LoggerType::LOGGER_SYNC);
    // builder->BuildEnableUsafeAsync();
    builder->BuildFormatter("[%c][%f:%l]%m%n");
    builder->BuildSinks<FileSink>("./logfile/async.log");
    builder->BuildSinks<StdoutSink>();
    builder->BuildSinks<RollBySizeSink>("./logfile/roll-async-by-size", 1024 * 1024);
    builder->build();

    test_log("sync_logger");
    return 0;
}